#!/usr/bin/env bash

mkdir -p mise-tasks && echo "" >mise-tasks/build.sh && chmod +x mise-tasks/build.sh
assert "mise task info build" 'Task: build
Description:
Source: ~/workdir/mise-tasks/build.sh
File: ~/workdir/mise-tasks/build.sh

Usage Spec:
  name build
  bin build'

assert_contains "mise task info build.sh --json" '"name": "build"'

assert_json_partial_object "mise task info build --json" "name,source,description" '{
  "name": "build",
  "source": "'"$PWD"'/mise-tasks/build.sh",
  "description": ""
}'

mise tasks add lint --depends "build -v" -- 'echo "linting!"'
assert_json "mise task info lint --json" "$(
  cat <<EOF
{
  "name": "lint",
  "aliases": [],
  "description": "",
  "source": "$(pwd)/mise.toml",
  "depends": [
    [
      "build",
      "-v"
    ]
  ],
  "depends_post": [],
  "wait_for": [],
  "env": {},
  "dir": null,
  "hide": false,
  "raw": false,
  "sources": [],
  "outputs": [],
  "shell": null,
  "quiet": false,
  "silent": false,
  "tools": {},
  "run": [
    "'echo \"linting!\"'"
  ],
  "file": null,
  "usage_spec": {
    "name": "lint",
    "bin": "lint",
    "cmd": {
      "full_cmd": [],
      "usage": "",
      "subcommands": {},
      "args": [],
      "flags": [],
      "mounts": [],
      "hide": false,
      "help": "",
      "name": "lint",
      "aliases": [],
      "hidden_aliases": [],
      "before_help_long": "- Depends: build -v",
      "examples": []
    },
    "config": {
      "props": {}
    },
    "usage": "",
    "complete": {}
  }
}
EOF
)"
